﻿using ERP.Workflow.Designer.Domain.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;

namespace ERP.Workflow.Designer.Domain
{

    public class FlowNodeExtendValue
    {
        public bool Contenteditable { get; set; }
        public string? Name { get; set; }
        public string? Icon { get; set; }
        public int Rotate { get; set; }
        public string? Code { get; set; }
        public int? OrderNo { get; set; }
        public NodeType NodeType { get; set; } = NodeType.General;
        public SplitRule SplitRule { get; set; } = SplitRule.SplitOR;
        public JoinRule JoinRule { get; set; } = JoinRule.SplitXOR;
        public ReposeType ReposeType { get; set; } = ReposeType.Any;
        public EntyType EntyType { get; set; } = EntyType.Auto;
        public ExitType ExitType { get; set; } = ExitType.Manual;
        public string? ActorAssembly { get; set; }
        public string? CirculatedAssembly { get; set; }
        public bool IsCanChangeCirculated { get; set; } = false;
        public bool IsCanEditForm { get; set; } = false;
        public ModeType ModeType { get; set; } = ModeType.PC;
        public bool HasHistoryCanSkip { get; set; }
        public bool NotActorIsCanSkip { get; set; } = false;
        public string? NotActorDefault { get; set; }
        public bool IsCanTransfer { get; set; } = false;
        public bool IsCanCirculated { get; set; } = false;
        public bool IsCanComments { get; set; } = false;
        public bool IsCanRejected { get; set; } = false;
        public bool IsCanWithdraw { get; set; } = false;

        public bool IsCanChangeTransfer { get; set; } = false;
        public bool IsAppend { get; set; } = false;
        public bool IsCanRush { get; set; }
        public bool IsFree { get; set; }




    }
    public class Node: AggregateRoot<Guid>, IMultiTenant, ISoftDelete
    {
        public Node(Guid id)
        {
            Id = id;
        }
        public Guid? TenantId { get; set; }
        public string? Title { get; set; }
        public double X { get; set; }
        public double Y { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }

        public Guid DefinitionId { get; set; }


        public Definition? Definition { get; set; }
        public List<Port> Ports { get; set; } = new List<Port>();

        public List<Link> Links { get; set; } = new List<Link>();
        public bool IsDeleted { get; set; }

        public void SetId(Guid id)
        { 
            this.Id = id;
        }
        public void SoftDelete() => IsDeleted = true;
        public void SetTenantId(Guid tenantId) =>TenantId = tenantId;
        public void Set(string? title,double x,double y,double width,double height)
        { 
            Title = title;
            X = x;
            Y = y;
            Width = width;
            Height = height;
        }
        public void SetExtraProperties(ExtraPropertyDictionary?  extra)
        {
            foreach (var item in extra)
            {
                ExtraProperties[item.Key] = extra[item.Key];
            }
          
        }
    }
}
